<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
<!-- View -->
<p id="oP"></p>
<input type="text" id="oInput">
<script>
const data = {
  str: 'hello',
  xxx: 'hello'
}

Object.keys(data).forEach(key => {
  defineReactive(data, key, data[key])
})

function defineReactive(obj, key, value) {
  Object.defineProperty(data, key,  {
    get() {
      return value
    },
    set(newValue) {
      value = newValue
      debugger
      oP.innerHTML = newValue
      oInput.value = newValue
    }
  })
}

oInput.oninput = function(e) {
  data.str = e.target.value
}
</script>
</body>
</html>